/* ======================================================= */
/**
 * File   : MenuBar.java
 * Date   : 3 mars 2010 at 10:44:31
 */
/* ======================================================= */
package fr.isima.isipaint.gui;

import java.util.HashMap;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/* ======================================================= */
/**
 * 
 * @author Daniel
 * 
 */
/* ======================================================= */
public class MenuBar extends JMenuBar {

	/** The serial number */
	private static final long serialVersionUID = 1L;

	/** Keys for the text dictonnary */
	private static final String FILE = "MENU_FILE";
	private static final String EDIT = "MENU_EDIT";
	private static final String TOOLS = "MENU_TOOLS";
	private static final String HELP = "MENU_HELP";

	private static final String NEW = "ITEM_NEW_FILE";
	private static final String QUIT = "ITEM_QUIT_FILE";
	private static final String UNDO = "ITEM_UNDO_EDIT";
	private static final String REDO = "ITEM_REDO_EDIT";
	private static final String CLEAR = "ITEM_CLEAR_TOOLS";
	private static final String ABOUT = "ITEM_ABOUT_HELP";

	/** The dictionnary of menu and item text */
	private HashMap<String, String> text = new HashMap<String, String>();

	
	/** The dictionnary of JMenu */
	//private HashMap<String, JMenu> menus = new HashMap<String, JMenu>();

	/** The dictionnary of JMenuItem */
	//private HashMap<String, JMenuItem> items = new HashMap<String, JMenuItem>();
	

	/* ======================================================= */
	/**
	 * Default constructor
	 */
	/* ======================================================= */
	public MenuBar() {

		text.put(TOOLS, "Tools");

		text.put(CLEAR, "clear");

		text.put(HELP, "Help");
		text.put(ABOUT, "about");

		text.put(NEW, "New");
		text.put(QUIT, "Quit");

		text.put(FILE, "File");
		
		text.put(UNDO, "Undo");
		text.put(REDO, "Redo");
		text.put(EDIT, "Edit");
		
		JMenu file = new JMenu(text.get(FILE));
		JMenu edit = new JMenu(text.get(EDIT));
		JMenu tools = new JMenu(text.get(TOOLS));
		JMenu help = new JMenu(text.get(HELP));
		
		add(file);
		add(edit);
		add(tools);
		add(help);
		
		file.add(new JMenuItem(text.get(NEW)));
		file.add(new JMenuItem(text.get(QUIT)));
		
		edit.add(new JMenuItem(text.get(UNDO)));
		edit.add(new JMenuItem(text.get(REDO)));
		
		tools.add(new JMenuItem(text.get(CLEAR)));
		
		help.add(new JMenuItem(text.get(ABOUT)));
		
		


/*
		for (Entry<String, String> entry : text.entrySet()) {
			System.out.println(text.entrySet().size());
			String key = entry.getKey();
			String value = entry.getValue();
			if (key.startsWith("MENU")) {
				JMenu menu = new JMenu(value);
				menus.put(key, menu);
				add(menu);
				
			} else {
				JMenuItem menuItem = new JMenuItem(value);
				items.put(key, menuItem);
			}
		}

		for (Entry<String, JMenuItem> entry : items.entrySet()) {
			System.out.println(text.entrySet().size());
			String key = entry.getKey();
			JMenuItem value = entry.getValue();
			menus.get("MENU_" + key.split("_")[2]).add(value);
		}
		*/
	}
}
